moduleLearningMap.controller("ConfigLearningMapExercise", function (ExerciseContentResource, LearningMapExerciseResource, $scope, $log, $state, $stateParams, GeneralResource, LoadingService, ConstantService, DialogService) {
    initPage($scope);
    $scope.$on("ngDialog.opened", function () {
        dialogOnLoad();
        $scope.findByKey(1);
    });

    // ------------------------------------------------------------------------------------------------------

    $scope.cancel = function () {
        DialogService.close();
    };

    $scope.findByKey = function (pageNo) {
        ExerciseContentResource.findPaginationListByKey({pageNo: pageNo - 1, pageSize: 10}, {key: $scope.queryKey}, function (queryResult) {
            $log.debug("查询结果", queryResult.data);
            $scope.results = queryResult.data;
            $scope.pagination.setPage(queryResult.data, pageNo);
        });
    };

    $scope.pagination = new Pagination();
    $scope.pagination.setPageClickFn($scope.findByKey);

    $scope.setCurrentContent = function (content) {
        $scope.currentContent.contentId = content.id;
        $scope.currentContent.learningMapCourseId = $scope.learningMapCourseId;
        $scope.currentContent.studyClassType = content.studyClassType;
        $scope.currentContent.name = content.name;
    }

    $scope.submit = function () {
        Alert.confirm(function () {
            LearningMapExerciseResource.quickConfig({}, $scope.currentContent, function () {
                Alert.success();
                DialogService.close();
            });
        });
    };
});